package dao;

import model.Professor;
import model.Usuario;

public class DAOProfessor extends DAODB4o<Professor>{
	
	public Professor find(String login){
		Professor p = new Professor();
		p.setLogin(login);
		return (Professor) super.find(p);	
	}
	
	public void persist(Professor p) throws Exception{
		DAOUsuario du = new DAOUsuario();
		Usuario u = du.findByLogin(p.getLogin());
		if (u==null)
			super.persist(p);			
		else
			throw new Exception("Nao e possivel persistir o professor "+p.getNome()+" - Login duplicado");
	}
}
